package com.kedacom.emptyproject.map.widget

import android.content.Context
import android.support.constraint.ConstraintLayout
import android.support.design.widget.CoordinatorLayout
import android.util.AttributeSet
import com.kedacom.emptyproject.MainApplication

/**
 * @author GuanHaoran
 * @description:
 * @date :2020/10/19 10:33 AM
 */
class MyCoordinatorLayoutView(
    context: Context,
    attributes: AttributeSet?,
    defStyle: Int = 0
) : CoordinatorLayout(context, attributes, defStyle) {

    private var params: ConstraintLayout.LayoutParams? = null
    private val bottomValue = 50f

    constructor(ctx: Context, attributes: AttributeSet?) : this(
        context = ctx,
        attributes = attributes
    )

    constructor(ctx: Context) : this(context = ctx, attributes = null)

    fun setPoi(midOffset: Float, float: Float) {

        /*  if (params == null)
              params = layoutParams as ConstraintLayout.LayoutParams



          params?.apply {
              if (float <= midOffset){
                  setPadding(
                      0,
                      0,
                      0,
                      dp2px(bottomValue)+((dp2px(70f-bottomValue)/midOffset)*float).toInt()
                  )
              }
              layoutParams = this

          }*/

    }


    fun dp2px(dpValue: Float): Int {
        var scale = 0f
        if (scale == 0f) {
            scale = MainApplication.applicationContext.resources.displayMetrics.density
        }
        return (dpValue * scale + 0.5f).toInt()
        /**
         * return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
         * dpValue,
         * MyApplication.getApplication().getResources().getDisplayMetrics());
         */
    }


}